package com.h3c.nem.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eos.common.util.CustomBeanUtils;
import com.eos.common.util.IdWorker;
import com.h3c.nem.dto.LoginUserDTO;
import com.h3c.nem.dto.TbFlowInstDTO;
import com.h3c.nem.dto.TbWorkerDTO;
import com.h3c.nem.dto.TbWorkerPromiseDTO;
import com.h3c.nem.entity.*;
import com.h3c.nem.mapper.*;
import com.h3c.nem.service.CommService;
import com.h3c.nem.service.ITbWorkerPromiseService;
import com.h3c.nem.utils.AppBusinessException;
import com.h3c.nem.utils.BusiEnumDefine;
import com.h3c.nem.utils.InitExampleOrderByUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * Copyright (C), 2020-2020, h3c
 * FileName: TbWorkerPromiseServiceImpl
 *
 * @Author: l22886
 * @Date: 2022-01-19
 * Description: tb_worker_promise serviceImpl
 * Version: 1.0
 */
@Slf4j
@Service
public class TbWorkerPromiseServiceImpl extends ServiceImpl<TbWorkerPromiseMapper, TbWorkerPromise> implements ITbWorkerPromiseService {

    @Resource
    private TbWorkerPromiseMapper tbWorkerPromiseMapper;
    @Autowired
    private SdFileTemplateServiceImpl fileTemplateService;
    @Autowired
    CommService commService;
    @Resource
    private TbFlowInstMapper tbFlowInstMapper;
    @Resource
    private SdUploadFileMapper sdUploadFileMapper;
    @Resource
    private TbWorkerMapper tbWorkerMapper;
    @Autowired
    private TbFlowInstServiceImpl tbFlowInstService;
    @Resource
    private TbApprovalRecordMapper tbApprovalRecordMapper;


    /**
     * @title: selectFuzzyByDto
     * @description: 模糊查询操作
     * @params: [ dto ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public List<TbWorkerPromiseDTO> selectFuzzyByDto(TbWorkerPromiseDTO dto) {
        //List<TbWorkerPromise> list = tbWorkerPromiseMapper.selectByExample(initFuzzyExample(dto));
        List<TbWorkerPromise> list = tbWorkerPromiseMapper.queryListByFuzzy(JSONObject.parseObject(JSONObject.toJSONString(dto),TbWorkerPromise.class));
        return JSONArray.parseArray(JSONArray.toJSONString(list), TbWorkerPromiseDTO.class);
    }

    /**
     * @title: selectByDto
     * @description: 精确查询操作
     * @params: [ dto ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public List<TbWorkerPromiseDTO> selectByDto(TbWorkerPromiseDTO dto) {
        //List<TbWorkerPromise> list = tbWorkerPromiseMapper.selectByExample(initExample(dto));
        List<TbWorkerPromise> list = tbWorkerPromiseMapper.queryList(JSONObject.parseObject(JSONObject.toJSONString(dto),TbWorkerPromise.class));
        return JSONArray.parseArray(JSONArray.toJSONString(list), TbWorkerPromiseDTO.class);
    }

    @Override
    public List<TbWorkerPromise> queryWorkerPromise(TbWorkerPromiseDTO dto) {
        String workerId = dto.getWorkerId();
        String flowId = dto.getFlowId();
        Integer promiseType = dto.getPromiseType();
//        if (!StringUtils.isEmpty(flowId)) {
            TbWorkerPromise query = new TbWorkerPromise();
            query.setWorkerId(workerId);
            query.setFlowId(flowId);
            query.setPromiseType(promiseType);
            List<TbWorkerPromise> workerPromises = tbWorkerPromiseMapper.queryListInOrder(query);
//            if (workerPromises.size() == 0) {
//                TbWorkerPromise promise = new TbWorkerPromise();
//                promise.setRecordId(IdWorker.nextId() + "");
//                promise.setPromiseType(promiseType);
//                promise.setPromiseOrder(1);
//                promise.setFlowId(flowId);
//                promise.setWorkerId(workerId);
//                promise.setOperateTime(new Date());
//                tbWorkerPromiseMapper.insertTbWorkerPromise(promise);
//            }
//            return tbWorkerPromiseMapper.queryListInOrder(query);
//        } else {
//            return tbWorkerPromiseMapper.queryWorkerPromise(workerId);
//        }

        return workerPromises;
    }

    /**
     * @title: insertDto
     * @description: 插入操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public Integer insertDto(TbWorkerPromiseDTO dto) {
        //if (null == dto.getId() || "".equals(dto.getId())) {
        //    String pkId = IdWorker.nextId() + "";
        //    dto.setId(pkId);
        //}
        return tbWorkerPromiseMapper.insertTbWorkerPromise(JSONObject.parseObject(JSON.toJSONString(dto), TbWorkerPromise.class));
    }

    /**
     * @title: updateDto
     * @description: 修改操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public Integer updateDto(TbWorkerPromiseDTO dto) {
        //if (null != dto && null != dto.getId() && !"".equals(dto.getId())) {
            return tbWorkerPromiseMapper.updateTbWorkerPromise(JSONObject.parseObject(JSON.toJSONString(dto), TbWorkerPromise.class));
            //return tbWorkerPromiseMapper.updateByPrimaryKey(JSONObject.parseObject(JSON.toJSONString(dto), TbWorkerPromise.class));
        //} else {
        //    return 0;
        //}
    }

    @Override
    @Transactional
    public void addWorkerPromise(TbWorkerPromiseDTO dto) { //传入, workerId, flowId, promiseType
        TbWorkerPromise workerPromise = new TbWorkerPromise();
        CustomBeanUtils.copyProperties(dto, workerPromise);
//        workerPromise.setRecordId(null);
//        List<TbWorkerPromise> tbWorkerPromises = tbWorkerPromiseMapper.queryListInOrder(workerPromise);
        workerPromise.setRecordId(IdWorker.nextId() + "");
        workerPromise.setOperateTime(new Date());
        tbWorkerPromiseMapper.insertTbWorkerPromise(workerPromise);
//        boolean flag = false;
//        for (int i = 0; i < tbWorkerPromises.size(); i++) {
//            TbWorkerPromise curPromise = tbWorkerPromises.get(i);
//            if (curPromise.getRecordId().equals(dto.getRecordId())) {
//                flag = true;
//                curPromise.setPromiseOrder(i);
//                workerPromise.setPromiseOrder(i + 1);
//                tbWorkerPromiseMapper.insertTbWorkerPromise(workerPromise);
//            } else if (flag){
//                curPromise.setPromiseOrder(i + 1);
//            } else {
//                curPromise.setPromiseOrder(i);
//            }
//            tbWorkerPromiseMapper.updateTbWorkerPromise(curPromise);
//        }

    }

    @Override
    public void modifyWorkerPromise(TbWorkerPromiseDTO dto) {
        String recordId = dto.getRecordId();
        TbWorkerPromise tbWorkerPromise = tbWorkerPromiseMapper.selectById(recordId);
        if (tbWorkerPromise == null) {
            throw new AppBusinessException("未找到承诺记录");
        } else {
            dto.setOperateTime(new Date());
            updateDto(dto);
        }
    }

    @Override
    @Transactional
    public void importWorkerPromise(MultipartFile uploadFile, String flowId) {
        String workerId = commService.getLoginUserId();
        String dataContent = parseUploadFile(uploadFile);
        JSONArray objects = JSONArray.parseArray(dataContent);
        List<TbWorkerPromise> workerPromiseList = new ArrayList<>();
        Date date = new Date();
        int i = 0;
        for (Object object : objects) {
            try {
                ((JSONObject) object).put("weight", Float.parseFloat(((JSONObject) object).get("weight").toString()) * 100);
            } catch (Exception e) {
                ((JSONObject) object).put("weight", 0);
            }
            TbWorkerPromise promise = JSONObject.parseObject(object.toString(), TbWorkerPromise.class);
            if (!StringUtils.isEmpty(promise.getPromisePoint()) && promise.getPromisePoint().length() > 2000) {
                throw new AppBusinessException("您输入的 承诺要素 内容过长, 最多支持2000字");
            }
            if (!StringUtils.isEmpty(promise.getPromiseTarget()) && promise.getPromiseTarget().length() > 2000) {
                throw new AppBusinessException("您输入的 目标 内容过长, 最多支持2000字");
            }
            if (!StringUtils.isEmpty(promise.getPromiseKeyActions()) && promise.getPromiseKeyActions().length() > 2000) {
                throw new AppBusinessException("您输入的 关键措施 内容过长, 最多支持2000字");
            }
            if (!StringUtils.isEmpty(promise.getFinishDate()) && promise.getFinishDate().length() > 120) {
                throw new AppBusinessException("您输入的 完成时间 内容过长, 最多支持120字");
            }
            promise.setPromisePoint(StringEscapeUtils.unescapeHtml4(promise.getPromisePoint()));
            promise.setPromiseTarget(StringEscapeUtils.unescapeHtml4(promise.getPromiseTarget()));
            promise.setPromiseKeyActions(StringEscapeUtils.unescapeHtml4(promise.getPromiseKeyActions()));
            promise.setFlowId(flowId);
            promise.setWorkerId(workerId);
            promise.setRecordId(IdWorker.nextId() + "");
            promise.setPromiseOrder(i++);
            promise.setOperateTime(date);
            workerPromiseList.add(promise);
        }
        tbWorkerPromiseMapper.deletePromise(workerId, flowId);
        workerPromiseList.forEach(promise -> tbWorkerPromiseMapper.insertTbWorkerPromise(promise));
    }

    public String parseUploadFile(MultipartFile file) {
        if (file == null || Objects.equals(file.getOriginalFilename(), "")) {
            throw new AppBusinessException("未取得文件");
        }
        String fileName = file.getOriginalFilename();
        String fileType = fileName.substring(fileName.lastIndexOf("."));
        if (!".xlsx".equalsIgnoreCase(fileType)) {
            throw new AppBusinessException("请使用系统提供的模板");
        }
        SdFileTemplate sdFileTemplate = fileTemplateService.queryTemplateByCode(BusiEnumDefine.PBC_IMPORT);
        return parsePbcExcel(file, sdFileTemplate);
    }

    public String parsePbcExcel(MultipartFile file, SdFileTemplate fileTemplate) {
        int startRow = fileTemplate.getStartRow() - 1;
        int startCol = fileTemplate.getStartCol() - 1;
        int colSize = fileTemplate.getColSize();
        int endCol = startCol + colSize;
        String fieldContent = fileTemplate.getFieldContent();
        String[] fieldArray = fieldContent.split(";");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        StringBuilder sb = new StringBuilder();
        InputStream inputStream = null;

        try {
            //1获取文件输入流
            inputStream = file.getInputStream();
            //2获取Excel工作簿
            XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
            //3获取Excel工作表
            XSSFSheet sheet = workbook.getSheetAt(0);

            int lastRowNum = sheet.getLastRowNum();
            sb.append("[\n");
            int curRowNum = 0;
            //承诺类型
            int promiseType = 1;
            if (!sheet.getRow(0).getCell(0).toString().contains("试用期员工月度考核目标表")) {
                throw new AppBusinessException("请使用系统提供的模板");
            }

            for (Row row : sheet) {
                //每个栏目的表头跳过
                if (curRowNum++ < startRow || (row.getCell(0) != null && row.getCell(0).toString().contains("承诺要素"))) {
                    continue;
                }
                //空行跳过
                if ((row.getCell(0) == null || StringUtils.isEmpty(row.getCell(0).toString()))
                        && (row.getCell(1) == null || StringUtils.isEmpty(row.getCell(1).toString()))
                        && (row.getCell(2) == null || StringUtils.isEmpty(row.getCell(2).toString()))
                        && (row.getCell(3) == null || StringUtils.isEmpty(row.getCell(3).toString()))) {
                    continue;
                }
                //总计结束
                if ((row.getCell(3) != null && row.getCell(3).toString().contains("总计：")) || curRowNum > 50) {
                    break;
                }
                //切换promise类型
                if (row.getCell(0) != null && row.getCell(0).toString().contains("个人发展目标承诺")) {
                    promiseType = 2;
                    continue;
                }
                sb.append(" {\n");
                int fieldIndex = 0;
                for (int i = startCol; i < endCol; i++) {
                    String fieldName = fieldArray[fieldIndex++];
                    if (fieldName.trim().equals("") || StringUtils.isEmpty((row.getCell(i)))) {
                        continue;
                    }
                    //获取单元格
                    Cell cell = row.getCell(i);
                    if (cell != null) {
                        //设置单元格类型
                        if (cell.getCellTypeEnum().toString().equals("NUMERIC") && cell.getDateCellValue().getTime() > 0) {//处理时间格式, 并且不包括weight
                            sb.append("    \"").append(fieldName).append("\":\"").append(sdf.format(new Date(cell.getDateCellValue().getTime()))).append("\"");
                        } else {
                            cell.setCellType(CellType.STRING);
//                            sb.append("    \"").append(fieldName).append("\":\"").append(cell.getStringCellValue()).append("\"");
                            sb.append("    \"").append(fieldName).append("\":\"").append(StringEscapeUtils.escapeJson(StringEscapeUtils.escapeHtml4(cell.getStringCellValue()))).append("\"");
                        }
                    } else {
                        sb.append("    \"").append(fieldName).append("\":\"\"");
                    }
                    sb.append(",\n");
                }
                sb.append("    \"promiseType\":\"").append(promiseType).append("\"\n");
                sb.append("  },\n");
            }
            String temp = sb.substring(0, sb.lastIndexOf(","));
            StringBuilder newSb = new StringBuilder();
            newSb.append(temp);
            sb = newSb;
            sb.append("]\n");
            workbook.close();
        } catch (IOException e) {
            e.printStackTrace();
            throw new AppBusinessException("文件解析异常");
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("导入模板,保存模板文件时解析出错");
                }
                inputStream = null;
            }
        }
        return sb.toString();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void submitPromise(String flowId, File file) {
        TbFlowInst tbFlowInst = tbFlowInstMapper.selectById(flowId);
        Integer flowStatus = tbFlowInst.getFlowStatus();
        if (!(flowStatus == BusiEnumDefine.flowStatusMonthlyPromise || flowStatus == BusiEnumDefine.flowStatusTurnFormalPlan)) {
            throw new AppBusinessException("当前流程不在待提交状态，无需提交");
        }
        LoginUserDTO loginUser = commService.getLoginUserDTO();
        TbWorker tbWorker = tbWorkerMapper.selectById(tbFlowInst.getWorkerId());
        TbFlowInstDTO tbFlowInstDTO = JSONObject.parseObject(JSONObject.toJSONString(tbFlowInst), TbFlowInstDTO.class);
        TbWorkerDTO tbWorkerDTO = JSONObject.parseObject(JSONObject.toJSONString(tbWorker), TbWorkerDTO.class);
        tbFlowInstService.forwardSpecificFlowInst(tbWorkerDTO, tbFlowInstDTO);
        QueryWrapper<SdUploadFile> fileWrapper = new QueryWrapper<>();
        fileWrapper.eq("busi_type", BusiEnumDefine.PROMISE_ATTACHMENT)
                        .eq("busi_id", flowId);
        List<SdUploadFile> sdUploadFiles = sdUploadFileMapper.selectList(fileWrapper);
        if (!CollectionUtils.isEmpty(sdUploadFiles)) {
            sdUploadFiles.forEach(existFile -> {
                commService.deleteSfsFile(existFile.getFileId());
            });
        }
        commService.uploadFileToSfs(BusiEnumDefine.PROMISE_ATTACHMENT, file, flowId);
        TbApprovalRecord record = new TbApprovalRecord();
        record.setApprovalId(IdWorker.nextId() + "");
        record.setFlowId(flowId);
        record.setFlowArriveTime(tbFlowInst.getArriveTime());
        record.setApprovalResult(BusiEnumDefine.APPROVAL_APPROVE);
        if (tbFlowInst.getFlowCode().equals(BusiEnumDefine.FLOW_MONTH_FILL)) {
            record.setApprovalType(BusiEnumDefine.APPROVAL_TYPE_MONTHLY_PROMISE);
        } else {
            record.setApprovalType(BusiEnumDefine.APPROVAL_TYPE_TURN_FORMAL_PLAN);
        }
        record.setApprovalUserId(loginUser.getUserId());
        record.setApprovalUserInfo(loginUser.getUserId() + "/" + loginUser.getUserName());
        record.setApprovalTime(new Date());
        record.setApprovalNote("提交承诺");
        tbApprovalRecordMapper.insertTbApprovalRecord(record);
    }
    /**
     * @title: deleteDto
     * @description: 删除操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public Integer deleteDto(TbWorkerPromiseDTO dto) {
        //if (null != dto && null != dto.getId() && !"".equals(dto.getId())) {
            return tbWorkerPromiseMapper.deleteTbWorkerPromise(JSONObject.parseObject(JSON.toJSONString(dto), TbWorkerPromise.class));
            //return tbWorkerPromiseMapper.deleteByPrimaryKey(dto.getId());
        //} else {
        //    return 0;
        //}
    }


    /**
     * @title: initFuzzyExample
     * @description: 初始化 模糊查询 example
     * @params: [ dto ]
     * @return: tk.mybatis.mapper.entity.Example
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    private Example initFuzzyExample(TbWorkerPromiseDTO dto) {
        Example example = InitExampleOrderByUtils.initExampleOrderBy(TbWorkerPromise.class, dto.getOrderBy());
        Example.Criteria criteriaName = example.createCriteria();
        if (null != dto) {
            if (null != dto.getRecordId() && !"".equals(dto.getRecordId())) {
                criteriaName.andLike("RecordId", "%" + dto.getRecordId() + "%");
            }
            if (null != dto.getWorkerId() && !"".equals(dto.getWorkerId())) {
                criteriaName.andLike("WorkerId", "%" + dto.getWorkerId() + "%");
            }
            if (null != dto.getFlowId() && !"".equals(dto.getFlowId())) {
                criteriaName.andLike("FlowId", "%" + dto.getFlowId() + "%");
            }
            if (null != dto.getPromiseType() && !"".equals(dto.getPromiseType())) {
                criteriaName.andLike("PromiseType", "%" + dto.getPromiseType() + "%");
            }
            if (null != dto.getPromisePoint() && !"".equals(dto.getPromisePoint())) {
                criteriaName.andLike("PromisePoint", "%" + dto.getPromisePoint() + "%");
            }
            if (null != dto.getPromiseTarget() && !"".equals(dto.getPromiseTarget())) {
                criteriaName.andLike("PromiseTarget", "%" + dto.getPromiseTarget() + "%");
            }
            if (null != dto.getPromiseKeyActions() && !"".equals(dto.getPromiseKeyActions())) {
                criteriaName.andLike("PromiseKeyActions", "%" + dto.getPromiseKeyActions() + "%");
            }
            if (null != dto.getFinishDate() && !"".equals(dto.getFinishDate())) {
                criteriaName.andLike("FinishDate", "%" + dto.getFinishDate() + "%");
            }
            if (null != dto.getWeight() && !"".equals(dto.getWeight())) {
                criteriaName.andLike("Weight", "%" + dto.getWeight() + "%");
            }
            if (null != dto.getFinishReply() && !"".equals(dto.getFinishReply())) {
                criteriaName.andLike("FinishReply", "%" + dto.getFinishReply() + "%");
            }
            if (null != dto.getScore() && !"".equals(dto.getScore())) {
                criteriaName.andLike("Score", "%" + dto.getScore() + "%");
            }
            if (null != dto.getSuggest() && !"".equals(dto.getSuggest())) {
                criteriaName.andLike("Suggest", "%" + dto.getSuggest() + "%");
            }
            if (null != dto.getOperateTime() && !"".equals(dto.getOperateTime())) {
                criteriaName.andLike("OperateTime", "%" + dto.getOperateTime() + "%");
            }
        }
        return example;
    }

    /**
     * @title: initExample
     * @description: 初始化 精确查询 example
     * @params: [ dto ]
     * @return: tk.mybatis.mapper.entity.Example
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    private Example initExample(TbWorkerPromiseDTO dto) {
        Example example = InitExampleOrderByUtils.initExampleOrderBy(TbWorkerPromise.class, dto.getOrderBy());
        Example.Criteria criteriaName = example.createCriteria();
        if (null != dto) {
            if (null != dto.getRecordId() && !"".equals(dto.getRecordId())) {
                criteriaName.andEqualTo("RecordId", dto.getRecordId());
            }
            if (null != dto.getWorkerId() && !"".equals(dto.getWorkerId())) {
                criteriaName.andEqualTo("WorkerId", dto.getWorkerId());
            }
            if (null != dto.getFlowId() && !"".equals(dto.getFlowId())) {
                criteriaName.andEqualTo("FlowId", dto.getFlowId());
            }
            if (null != dto.getPromiseType() && !"".equals(dto.getPromiseType())) {
                criteriaName.andEqualTo("PromiseType", dto.getPromiseType());
            }
            if (null != dto.getPromisePoint() && !"".equals(dto.getPromisePoint())) {
                criteriaName.andEqualTo("PromisePoint", dto.getPromisePoint());
            }
            if (null != dto.getPromiseTarget() && !"".equals(dto.getPromiseTarget())) {
                criteriaName.andEqualTo("PromiseTarget", dto.getPromiseTarget());
            }
            if (null != dto.getPromiseKeyActions() && !"".equals(dto.getPromiseKeyActions())) {
                criteriaName.andEqualTo("PromiseKeyActions", dto.getPromiseKeyActions());
            }
            if (null != dto.getFinishDate() && !"".equals(dto.getFinishDate())) {
                criteriaName.andEqualTo("FinishDate", dto.getFinishDate());
            }
            if (null != dto.getWeight() && !"".equals(dto.getWeight())) {
                criteriaName.andEqualTo("Weight", dto.getWeight());
            }
            if (null != dto.getFinishReply() && !"".equals(dto.getFinishReply())) {
                criteriaName.andEqualTo("FinishReply", dto.getFinishReply());
            }
            if (null != dto.getScore() && !"".equals(dto.getScore())) {
                criteriaName.andEqualTo("Score", dto.getScore());
            }
            if (null != dto.getSuggest() && !"".equals(dto.getSuggest())) {
                criteriaName.andEqualTo("Suggest", dto.getSuggest());
            }
            if (null != dto.getOperateTime() && !"".equals(dto.getOperateTime())) {
                criteriaName.andEqualTo("OperateTime", dto.getOperateTime());
            }
        }
        return example;
    }


}
